#!/usr/bin/python3
import socket
import sys
import os

# Settings
servHost = socket.gethostname()
servPort = 7767

# Config
serverSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 
serverSocket.bind((servHost, servPort))
serverSocket.listen(5)

# Listen
while True:
    clientSocket, clientAddress = serverSocket.accept()
    print("Address: %s" % str(clientAddress))
    rid = clientSocket.recv(1024)
    clientSocket.close()
    os.system("sudo docker run -v /var/www/judge/data:/var/www/judge/data judge/default /usr/bin/python3 /var/www/judge/data/Judger.py "+rid.decode('UTF-8'))
